<!-- Main Sidebar Container -->
<aside class="main-sidebar sidebar-dark-primary elevation-4">
  <!-- Brand Logo -->
  <a href="javascript:void(0);" class="brand-link">
    <img src="/static/adminlte/dist/img/AdminLTELogo.png" alt="AdminLTE Logo" class="brand-image img-circle elevation-3"
      style="opacity: .8">
    <span class="brand-text font-weight-light">{$SETTING.website_name}</span>
  </a>

  <!-- Sidebar -->
  <div class="sidebar">
    <!-- Sidebar user panel (optional) -->
    <div class="user-panel mt-3 pb-3 mb-3 d-flex">
      <div class="image">
        <img src="/static/adminlte/dist/img/avatar5.png" class="img-circle elevation-2" alt="User Image">
      </div>
      <div class="info">
        <a href="#" class="d-block">{$ADMIN.username}，你好！</a>
      </div>
    </div>

    <!-- Sidebar Menu -->
    <nav class="mt-2">
      <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
        <!-- Add icons to the links using the .nav-icon class
               with font-awesome or any other icon font library -->
        <li class="nav-item has-treeview">
          <a href="#" class="nav-link active">
            <i class="nav-icon fas fa-tachometer-alt"></i>
            <p>
              欢迎使用
              <i class="right fas fa-angle-left"></i>
            </p>
          </a>
          <ul class="nav nav-treeview">
            <li class="nav-item">
              <a href="/frameset/index" class="nav-link">
                <i class="far fa-circle nav-icon"></i>
                <p>后台首页</p>
              </a>
            </li>

            <li class="nav-item">
              <a href="/frameset/logout" class="nav-link" onclick="return confirm('确定要退出么？');">
                <i class="far fa-circle nav-icon"></i>
                <p>安全退出</p>
              </a>
            </li>
          </ul>
        </li>
        <?php
        $_MENU=$CORE_CONF->user_menu($ADMIN['groupid'],$ADMIN['userid'],$CORE_CONF->MENU);
        ?>
        {foreach $CORE_CONF->MODULE as $_moduleid=>$_module }
        <?php
        if(empty($_MENU[$_moduleid])) continue;
        $_menu=$_MENU[$_moduleid];
        ?>
        <li class="nav-item has-treeview">
            <a href="#" class="nav-link active">
              <i class="nav-icon fas fa-tachometer-alt"></i>
              <p>
                {$_module.module_cn}
                <i class="right fas fa-angle-left"></i>
              </p>
            </a>
            
            <ul class="nav nav-treeview">
              {foreach $_menu as $_m}
              <?php
              if(isset($_m['url'])){
                $_url=$_m['url'];
              }else{
                $_url="/".$_module['module_en']."/".$_m['name'];
              }
              ?>
              <li class="nav-item">
                <a href="{$_url}" class="nav-link">
                  <i class="far fa-circle nav-icon"></i>
                  <p>{$_m.chinese}</p>
                </a>
              </li>
              {/foreach}
            </ul>
          </li>
          {/foreach}  
        <!--
        <li class="nav-item has-treeview">
          <a href="#" class="nav-link active">
            <i class="nav-icon fas fa-tachometer-alt"></i>
            <p>
              系统设置
              <i class="right fas fa-angle-left"></i>
            </p>
          </a>
          <ul class="nav nav-treeview">
            <li class="nav-item">
              <a href="/admin/safe" class="nav-link">
                <i class="far fa-circle nav-icon"></i>
                <p>修改密码</p>
              </a>
            </li>
            <li class="nav-item">
              <a href="/admin/setting" class="nav-link">
                <i class="far fa-circle nav-icon"></i>
                <p>网站设置</p>
              </a>
            </li>

          </ul>
        </li>

        <li class="nav-item has-treeview">
          <a href="#" class="nav-link active">
            <i class="nav-icon fas fa-tachometer-alt"></i>
            <p>
              会员管理
              <i class="right fas fa-angle-left"></i>
            </p>
          </a>
          <ul class="nav nav-treeview">
            <li class="nav-item">
              <a href="/member/add" class="nav-link">
                <i class="far fa-circle nav-icon"></i>
                <p>添加会员</p>
              </a>
            </li>
            <li class="nav-item">
              <a href="/member/lst" class="nav-link">
                <i class="far fa-circle nav-icon"></i>
                <p>会员列表</p>
              </a>
            </li>
            <li class="nav-item">
              <a href="/member/login_log" class="nav-link">
                <i class="far fa-circle nav-icon"></i>
                <p>登录日志</p>
              </a>
            </li>
            <li class="nav-item">
              <a href="/member/setting" class="nav-link">
                <i class="far fa-circle nav-icon"></i>
                <p>模块设置</p>
              </a>
            </li>

          </ul>
        </li>

        <li class="nav-item has-treeview">
          <a href="#" class="nav-link active">
            <i class="nav-icon fas fa-tachometer-alt"></i>
            <p>
              文章管理
              <i class="right fas fa-angle-left"></i>
            </p>
          </a>
          <ul class="nav nav-treeview">
            <li class="nav-item">
              <a href="/article/add" class="nav-link">
                <i class="far fa-circle nav-icon"></i>
                <p>添加文章</p>
              </a>
            </li>
            <li class="nav-item">
              <a href="/article/lst" class="nav-link">
                <i class="far fa-circle nav-icon"></i>
                <p>文章列表</p>
              </a>
            </li>
            <li class="nav-item">
              <a href="/article/category_add" class="nav-link">
                <i class="far fa-circle nav-icon"></i>
                <p>添加分类</p>
              </a>
            </li>
            <li class="nav-item">
              <a href="/article/category_lst" class="nav-link">
                <i class="far fa-circle nav-icon"></i>
                <p>分类列表</p>
              </a>
            </li>
            <li class="nav-item">
              <a href="/article/setting" class="nav-link">
                <i class="far fa-circle nav-icon"></i>
                <p>模块设置</p>
              </a>
            </li>

            <li class="nav-item">
                <a href="/article/clear_attachments" class="nav-link">
                  <i class="far fa-circle nav-icon"></i>
                  <p>清理垃圾附件</p>
                </a>
              </li>

            <li class="nav-item">
                <a href="/article/test" class="nav-link">
                  <i class="far fa-circle nav-icon"></i>
                  <p>测试</p>
                </a>
              </li>

          </ul>
        </li>
      -->
      </ul>
    </nav>
    <!-- /.sidebar-menu -->
  </div>
  <!-- /.sidebar -->
</aside>

<script>
    $(document).ready(function(e) {
	  $.ajaxSetup({async:false});
      $.post('/frameset/get_menu_current',{},function(data){
        $('ul.nav-sidebar > li.has-treeview').eq(parseInt(data.result.a)).children('a:first').trigger('click');
        if(data.result.href!='#'){
          $('a.nav-link').each(function(index,element){
            if($(element).attr('href')==data.result.href) $(element).addClass('active');
          });
        }
      },'json');
    
      $('ul.nav-sidebar > li.has-treeview > a[href="#"]').click(function(){
        var a=parseInt($(this).parent().index('.has-treeview'));
        $.post('/frameset/set_menu_current',{a:a,href:'#'},function(data){}
  
        ,'json');
      });
  
      $('ul.nav-sidebar > li.has-treeview > ul.nav-treeview > li.nav-item > a.nav-link').click(function(){
        var a=parseInt($(this).parent().parent().parent().index('.has-treeview'));
        $.post('/frameset/set_menu_current',{a:a,href:$(this).attr('href')},function(data){}
  
        ,'json');
      });
	  $.ajaxSetup({async:true});
    });
  </script>